﻿namespace JxcLite.Services;

public interface IBaseDataService : IService
{
    Task<PagingResult<GoodsInfo>> QueryGoodsesAsync(PagingCriteria criteria);
    Task<List<GoodsInfo>> GetGoodsesAsync();
    Task<Result> DeleteGoodsesAsync(List<GoodsInfo> infos);
    Task<Result> SaveGoodsAsync(UploadInfo<GoodsInfo> info);

    Task<PagingResult<PartnerInfo>> QueryPartnersAsync(PagingCriteria criteria);
    Task<Result> DeletePartnersAsync(List<PartnerInfo> infos);
    Task<Result> SavePartnerAsync(UploadInfo<PartnerInfo> info);
}

[Client]
class BaseDataClient(HttpClient http) : ClientBase(http), IBaseDataService
{
    public Task<PagingResult<GoodsInfo>> QueryGoodsesAsync(PagingCriteria criteria)
    {
        return Http.QueryAsync<GoodsInfo>("/BaseData/QueryGoodses", criteria);
    }

    public Task<List<GoodsInfo>> GetGoodsesAsync()
    {
        return Http.GetAsync<List<GoodsInfo>>("/BaseData/GetGoodses");
    }

    public Task<Result> DeleteGoodsesAsync(List<GoodsInfo> infos)
    {
        return Http.PostAsync("/BaseData/DeleteGoodses", infos);
    }

    public Task<Result> SaveGoodsAsync(UploadInfo<GoodsInfo> info)
    {
        return Http.PostAsync("/BaseData/SaveGoods", info);
    }


    public Task<PagingResult<PartnerInfo>> QueryPartnersAsync(PagingCriteria criteria)
    {
        return Http.QueryAsync<PartnerInfo>("/BaseData/QueryPartners", criteria);
    }

    public Task<Result> DeletePartnersAsync(List<PartnerInfo> infos)
    {
        return Http.PostAsync("/BaseData/DeletePartners", infos);
    }

    public Task<Result> SavePartnerAsync(UploadInfo<PartnerInfo> info)
    {
        return Http.PostAsync("/BaseData/SavePartner", info);
    }
}